package com.hycgy.system.service;

import cn.dev33.satoken.stp.StpUtil;
import com.hycgy.system.mapper.UserMapper;
import com.hycgy.system.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 罗老师
 * @Date 2025/5/28 10:36
 */
@Service
public class UserService {
    @Autowired
    UserMapper userMapper;
    public void login(String accountName,String password){
        //先根据accountName查询出用户
        User user = userMapper.getUserByAccountName(accountName);
        //根据password判断和查询出来的用户密码是否一致，一致说明登录成功
        if (password.equals(user.getPassword())) {
            StpUtil.login(user.getUserId());
            return;
        }
        throw new IllegalArgumentException("用户名或密码错误");
        //否则说明登录失败
    }
}
